package com.ilovepostcard;

import android.os.Bundle;

import com.ilovepostcard.model.Postcard;
import com.ilovepostcard.view.PostcardBottomBar;
import com.ilovepostcard.view.PostcardDetailView;

public class PostcardActivity extends BaseActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_postcard);
        PostcardDetailView detailView = (PostcardDetailView)findViewById(R.id.postcard_detail_view);
        Postcard postcard = getPostcard();
        if (postcard != null)
            detailView.setPostcard(postcard);
        
        String view = getIntent().getExtras().getString("view");
        if ("my".equals(view)) {
            PostcardBottomBar bar = (PostcardBottomBar) findViewById(R.id.discover_bottombar);
            bar.setView(view);
        }
    }

    private Postcard getPostcard() {
        Object obj = getIntent().getExtras().getSerializable("postcard");
        if (obj instanceof Postcard)
            return (Postcard) obj;
        return null;
    }
    
}
